package util;

//////////////////////////////////////////////////

/*import com.google.api.client.googleapis.auth.clientlogin.ClientLogin;
 import com.google.api.client.googleapis.auth.clientlogin.ClientLogin.Response;
 import com.google.api.client.http.HttpTransport;
 import com.google.api.client.http.javanet.NetHttpTransport;
 import com.google.api.client.http.json.JsonHttpRequest;
 import com.google.api.client.http.json.JsonHttpRequestInitializer;
 import com.google.api.client.json.jackson.JacksonFactory;
 import com.google.api.services.calendar.Calendar;
 import com.google.api.services.calendar.CalendarRequest;
 import com.google.api.services.calendar.model.*;

 import com.google.gdata.client.*;
 import com.google.gdata.client.calendar.*;
 import com.google.gdata.data.*;
 import com.google.gdata.data.acl.*;
 import com.google.gdata.data.calendar.*;
 import com.google.gdata.data.extensions.*;
 */
import com.google.gdata.client.calendar.CalendarService;
import com.google.gdata.data.calendar.CalendarEntry;
import com.google.gdata.data.calendar.CalendarEventEntry;
import com.google.gdata.data.calendar.CalendarEventFeed;
import com.google.gdata.data.calendar.CalendarFeed;
import com.google.gdata.data.extensions.When;
import com.google.gdata.util.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.io.*;

//////////////////////////////////////////////////

public class CalendarUtil {

	// static HttpTransport transport = new NetHttpTransport();

	public CalendarUtil() {

	}

	public static List<CalendarEventEntry> retrieveAllEvents(String strEmail,
			String strPassword) {
		List<CalendarEventEntry> events = new ArrayList<CalendarEventEntry>();
		try {
			CalendarService service = new CalendarService("BuzzSystem-v1.0");
			service.setUserCredentials("buzzsystememail@gmail.com",
					"buzzsystemtest");

			URL feedUrl = new URL(
					"https://www.google.com/calendar/feeds/default/private/full");
			CalendarEventFeed resultFeed = service.getFeed(feedUrl,
					CalendarEventFeed.class);
			events = resultFeed.getEntries();
			resultFeed.getEntries();

			System.out.println("Your calendars:");
			System.out.println();

			for (int i = 0; i < events.size(); i++) {
				CalendarEventEntry entry = events.get(i);
				// When bipbip;
				// System.out.println("\t" + entry.getTitle().getPlainText());
				// System.out.println("\t" +
				// entry.getTimes().get(0).getStartTime().toString() + " -> " +
				// entry.getTimes().get(0).getEndTime().toString());
			}
		} catch (AuthenticationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ServiceException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return events;

	}

	public static boolean delete(String strEmail, String strPassword,
			String strContactId) {
		boolean deletedResult = false;

		return deletedResult;
	}

	public static boolean update(String strEmail, String strPassword,
			String strContactId) {
		return true;
	}
}

//class Constants {
//	final static String AUTH_TOKEN_TYPE = "cl";
//	final static String USERNAME = "buzzsystememail@gmail.com";
//	final static String PASSWORD = "buzzsystemtest";
//}